package org.example.niceoil.dao;

import org.example.niceoil.entity.teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.example.niceoil.mapper.teacherMapper;

import java.util.List;

@Repository
public class teacherDao {

    private final teacherMapper teacherMapper;

    @Autowired
    public teacherDao(teacherMapper teacherMapper) {
        this.teacherMapper = teacherMapper;
    }

    // 查询所有教师
    public List<teacher> selectAll() {
        // 传递 null 代表查询全部
        return teacherMapper.selectList(null);
    }

    // 查询 id 最大的教师
    public teacher selectMax() {
        return teacherMapper.selectMax();
    }

    // 根据名字查询教师
    public teacher selectByName(String name) {
        return teacherMapper.selectByName(name);
    }
    public teacher selectByNameAndId(String name,Long id) {
        return teacherMapper.selectByNameAndId(name,id);
    }

    // 新增教师
    public int insertteacher(Long id, String name) {
        return teacherMapper.insertTeacher(id, name);
    }

    // 根据 ID 删除教师
    public int deleteteacher(Long id) {
        return teacherMapper.deleteTeacher(id);
    }

    // 修改教师信息
    public int updateteacher(Long id, String name) {
        return teacherMapper.updateTeacher(id, name);
    }
}
